<?php
defined('IN_IXDCW') or exit('Access Denied');
include tpl('header');
show_menu($menus);
?>
<form method="post" action="?" id="runcode_form" target="_blank">
    <input type="hidden" name="moduleid" value="<?php echo $moduleid;?>"/>
    <input type="hidden" name="file" value="<?php echo $file;?>"/>
    <input type="hidden" name="action" value="runcode"/>
    <input type="hidden" name="codes" id="codes" value=""/>
</form>
<form method="post" action="?" id="dform" onsubmit="return check();">
    <input type="hidden" name="moduleid" value="<?php echo $moduleid;?>"/>
    <input type="hidden" name="file" value="<?php echo $file;?>"/>
    <input type="hidden" name="action" value="<?php echo $action;?>"/>
    <input type="hidden" name="forward" value="<?php echo $forward;?>"/>
    <input type="hidden" name="pid" value="<?php echo $p['pid'];?>"/>
    <input type="hidden" name="pay[pid]" value="<?php echo $p['pid'];?>"/>
    <input type="hidden" name="pay[payid]" value="<?php echo $user['payid'];?>"/>
    <div class="tt">编辑广告订单</div>
    <table cellpadding="2" cellspacing="1" class="tb">
        <tr>
            <td class="tl"><span class="f_hid">*</span> 广告位</td>
            <td class="f_b">&nbsp;<?php echo $p['name'];?></td>
        </tr>
        <tr>
            <td class="tl"><span class="f_hid">*</span> 广告类型</td>
            <td class="f_gray">&nbsp;<?php echo $TYPE[$p['typeid']];?></td>
        </tr>
        <tr>
            <td class="tl"><span class="f_red">*</span> 用户名</td>
            <td><input name="pay[username]" type="text" size="15" value="<?php echo $user['userid'] ? get_user($user['userid'],'userid','username') : '';?>"/></td>
        </tr>

        <tr>
            <td class="tl"><span class="f_red">*</span> 投放时段</td>
            <td><?php echo dcalendar('pay[starttime]', timetodate($user['starttime'], 3));?> 至 <?php echo dcalendar('pay[overtime]', timetodate($user['overtime'], 3));?>&nbsp;
                <select onchange="Dd('payovertime').value=this.value;">
                    <option value="">快捷选择</option>
					<?php $FTIME = strtotime($startime);?>
                    <option value="<?php echo timetodate($FTIME + 86400 * 7, 3);?>">一周</option>
                    <option value="<?php echo timetodate($FTIME + 86400 * 15, 3);?>">半月</option>
                    <option value="<?php echo timetodate($FTIME + 86400 * 30, 3);?>">一月</option>
                    <option value="<?php echo timetodate($FTIME + 86400 * 91, 3);?>">三月</option>
                    <option value="<?php echo timetodate($FTIME + 86400 * 182, 3);?>">半年</option>
                    <option value="<?php echo timetodate($FTIME + 86400 * 365, 3);?>">一年</option>
                    <option value="<?php echo timetodate($FTIME + 86400 * 365 * 2, 3);?>">二年</option>
                    <option value="<?php echo timetodate($FTIME + 86400 * 365 * 3, 3);?>">三年</option>
                </select>&nbsp;<span id="dtime" class="f_red"></span></td>
        </tr>
        <?php if($placeResidueCity['0']){ ?>
        <tr>
            <td class="tl"><span class="f_hid">*</span> 地区(主站)</td>
            <td>

            <input type="checkbox" name="pay[areaids][]" value="0" <?php echo in_array(0 , $checked) ?  'checked' : ''; ?>> 主站

            </td>
        </tr>
        <?php } ?>
        <tr>
            <td class="tl"><span class="f_hid">*</span> 地区(分站)</td>
            <td>
			<?php foreach($placeResidueCity as $areaids){ ?>
				<?php if($areaids['areaid']!=0){ ?>
                <input type="checkbox" name="pay[areaids][]" value="<?php echo $areaids['areaid'];?>" <?php echo in_array($areaids['areaid'] , $checked) ?  'checked' : ''; ?>> <?php echo $areaids['name'];?>
                <?php } ?>
            <?php } ?>
            </td>
        </tr>


    </table>
    <div class="sbt"><input type="submit" name="submit" value=" 确 定 " class="btn"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value=" 返 回 " class="btn" onclick="history.back(-1);"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="btn" onclick="if(confirm('确定要删除此订单吗？\n\n订单下的所有广告也将被删除\n\n此操作不可撤销\n\n')){window.location ='?moduleid=<?php echo $moduleid;?>&file=<?php echo $file;?>&action=del_user&pid=<?php echo $p['pid'];?>&payid=<?php echo $user['payid'];?>'}else{return false;}" value="删除此用户订单"/></div>
</form>
<?php load('clear.js'); ?>
<script type="text/javascript">
    function check() {
        var l;
        var f;
        var t = <?php echo $p['typeid'];?>;
        f = 'title';
        l = Dd(f).value.length;
        if (l < 1) {
            Dmsg('请填写广告名称', f);
            return false;
        }
        if (Dd('adfromtime').value.length != 10 || Dd('adtotime').value.length != 10) {
            Dmsg('请填写投放时段', 'time');
            return false;
        }
        if (t == 1 || t == 7) {
            f = 'code';
            l = Dd(f).value.length;
            if (l < 5) {
                Dmsg('请填写广告代码', f);
                return false;
            }
        } else if (t == 2) {
            f = 'text_name';
            l = Dd(f).value.length;
            if (l < 2) {
                Dmsg('请填写链接文字', f);
                return false;
            }
            f = 'text_url';
            l = Dd(f).value.length;
            if (l < 12) {
                Dmsg('请填写链接地址', f);
                return false;
            }
        } else if (t == 3 || t == 5) {
            f = 'thumb';
            l = Dd(f).value.length;
            if (l < 2) {
                Dmsg('请填写图片地址', f);
                return false;
            }
            if (t == 5 && ext(Dd(f).value) != 'jpg') {
                Dmsg('仅支持JPG格式图片', f);
                return false;
            }
        } else if (t == 4) {
            f = 'flash';
            l = Dd(f).value.length;
            if (l < 5) {
                Dmsg('请填写Flash地址', f);
                return false;
            }
        } else if (t == 6) {
            f = 'key_id';
            l = Dd(f).value.length;
            if (l < 1) {
                Dmsg('请填写信息ID', f);
                return false;
            }
        }
        return true;
    }
    function runcode() {
        if (Dd('code').value.length < 3) {
            Dmsg('请填写代码', 'code');
            return false;
        }
        Dd('codes').value = Dd('code').value;
        Dd('runcode_form').submit();
    }
</script>
<script type="text/javascript">Menuon(2);</script>
<?php include tpl('footer'); ?>